home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: ncrutr.Utrecht.NCR.COM!news
- From: Robert Luursema <RLuursem@wcnd.ns-nl.att.com>
- Subject: Re: How do I round and truncate floats to integers?
- Message-ID: <Dn2vz8.11s@ncrutr.Utrecht.NCR.COM>
- Sender: news@ncrutr.Utrecht.NCR.COM
- Reply-To: RLuursem@wcnd.ns-nl.att.com (ROBL)
- Organization: AT&T WCND
- X-Newsreader: DiscussIT 2.5.1.3 for MS Windows [AT&T Software Products Division]
- References: <fcusack-1502961821280001@mudskipper.cac.psu.edu>
- Date: Tue, 20 Feb 1996 14:23:31 GMT
-
- > ==========frank., 96/02/15==========
- > typecasting will truncate. To round, add 0.5, then truncate (by
- > typecasting). Note that this is not "proper" rounding which
- changes which
- > way the rounding occurs if the decimal is exactly 0.5 depending
- > on whether the integer part is even or odd.
- > ie, 5.5 rounds to 6; but 4.5 rounds to 4
-
- If your compiler behaves like this, you certainly have a problem
- (or a faulty pentium :-)
-
-
- > ~Frank
- > -- I am Pentium of Borg. Division is futile. You will be
- > approximated. --
- > -- If you build it, they will come -->
- > http://www.tdx.org/~fcusack/ --
- > -- PGP key fingerprint: 01 C0 C0 B9 CC 78 67 0F 3F 64 80 65 8B
- > 0F F9 EA --
-
-
- Robert Luursema
- AT&T NWS Utrecht, the Netherlands
- rluursem@wcnd.utrecht.attgis.com
-